local yaowu = fk.CreateSkill {

  name = "joyex__yaowu",

  tags = { Skill.Compulsory, },

}



yaowu:addEffect(fk.DamageInflicted, {
  name = "joyex__yaowu",
  frequency = Skill.Compulsory,
  events = {fk.DamageInflicted},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(yaowu.name) and not data.chain and data.card and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if data.card.color == Card.Black and not player.dead then
      player.room:notifySkillInvoked(player, yaowu.name, "masochism")
      player:broadcastSkillInvoke(yaowu.name, 1)
      player:drawCards(1, yaowu.name)
    elseif data.card.color == Card.Red and not data.from.dead then
      player.room:notifySkillInvoked(player, yaowu.name, "negative")
      player:broadcastSkillInvoke(yaowu.name, 2)
      local from = data.from
        from:drawCards(1, yaowu.name)
    end
    if not player.dead and data.card and player.room:getCardArea(data.card) == Card.Processing then
      player.room:obtainCard(player, data.card, true, fk.ReasonPrey)
    end
  end
})

return yaowu